﻿using System.IO;

namespace DBController
{
    public class Controller
    {
        static Controller()
        {
            if (!Directory.Exists(dir_App))
            {
                Directory.CreateDirectory(dir_App);
            }

            if (!Directory.Exists(dir_AppConfig))
            {
                Directory.CreateDirectory(dir_AppConfig);
            }

            if (!Directory.Exists(dir_AccountDB))
            {
                Directory.CreateDirectory(dir_AccountDB);
            }
        }

        private static readonly string dir_App = "App";
        private static readonly string dir_AppConfig = @"App\AppConfig";
        private static readonly string dir_AccountDB = @"App\AccountDB";

        private static readonly string file_AppConfig = @"App\AppConfig\App.Config";
        private static readonly string file_AccountDB = @"App\AccountDB\AccountDB.db";

        /// <summary>
        /// 配置文件
        /// </summary>
        public static AppConfig AppConfig
        {
            get { return new AppConfig(file_AppConfig); }
        }

        private static AccountDB accountDB;

        /// <summary>
        /// 账号管理库
        /// </summary>
        public static AccountDB AccountDB
        {
            get
            {
                if (accountDB == null)
                {
                    accountDB = new AccountDB(file_AccountDB);
                }
                return accountDB;
            }
        }
    }
}